public class ContainerWithMostWater {

    public int maxArea(int[] height) {
        int left = 0, right = height.length - 1;
        int sMax = 0;
        while (left < right) {
            int s = Math.min(height[left], height[right]) * (right - left);
            if(s > sMax) {
                sMax = s;
            }
            if(height[left] < height[right]) {
                left++;
            }else {
                right--;
            }
        }
        return sMax;
    }
}
